package mythread;

public class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("继承 Thread 类创建线程");

    }

    public static void main(String[] args) {
        Thread t3 = new Thread(() -> System.out.println("使用匿名类创建 Thread 子类对象"));
        Thread t4 = new Thread(() -> {
            System.out.println("使用匿名类创建 Thread 子类对象");
        });
        t3.start();
        t4.run();
    }
    public static void main2(String[] args) {
        Thread myThread = new Thread() {
            @Override
            public void run() {
                System.out.println("匿名内部类创建 Thrad 对象");
            }
        };
        myThread.start();
    }
    public static void main1(String[] args) {
        MyThread t = new MyThread();
        t.start();
    }
}
